package personal.xjl._23java1studentdemo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import personal.xjl._23java1studentdemo.mapper.CourseMapper;
import personal.xjl._23java1studentdemo.model.Course;
import personal.xjl._23java1studentdemo.service.CourseService;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    @Override
    public List<Course> findAll() {
        return courseMapper.selectAll();
    }

    @Override
    public List<Course> findByPage(int currPage, int pageSize) {
        int fromIndex = (currPage<1)?0:(currPage-1)*pageSize;
        return courseMapper.selectByPage(fromIndex, pageSize);
    }
}
